{{!< default}}

<div class="content-wrap page-archive">
    <div id="content" class="content">
        <section id="posts" class="posts-collapse">
            <span class="archive-move-on"></span>
            <span class="archive-page-counter">好! 目前共计&nbsp;<span id="r-post-total"></span>&nbsp;篇日志。 继续努力。</span>
            <div id="hidden-temp-container" style="display: none;">
                {{#get "posts" limit="all" fields="title,url,created_at,published_at" as |articles|}}
                    {{#foreach articles}}
                        <article class="" itemscope="" itemtype="http://schema.org/Article">
                            <header class="post-header">
                                <h1 class="post-title">
                                    <a class="post-title-link" href="{{url}}" itemprop="url">
                                        <span itemprop="name">{{title}}</span>
                                    </a>
                                </h1>
                                <div class="post-meta">
                                    <time year="{{date format='YYYY'}}">
                                        {{date format='MM-DD'}}
                                    </time>
                                </div>
                            </header>
                        </article>
                    {{/foreach}}
                {{/get}}
            </div>
        </section>
    </div>
</div>
<div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
        <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
        <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
        <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
</div>
<aside id="sidebar" class="sidebar" style="display: none; width: 320px;">
    <div class="sidebar-inner">
        {{> sidebar}}
    </div>
</aside>
<script type="text/javascript">
    var counter = 0;
    var currentYear;
    $("#hidden-temp-container article").each(function(){
        if (counter == 0){
            currentYear = $(this).find("time").attr("year");
            $("#posts").html($("#posts").html() + '<div class="collection-title">' +
                    '<h2 class="archive-year motion-element" id="archive-year-' + currentYear + '" style="opacity: 1;">' + currentYear + '</h2>' +
                    '</div>');
        }
        if($(this).find("time").attr("year") < currentYear) {
            currentYear = $(this).find("time").attr("year");
            $("#posts").html($("#posts").html() + '<div class="collection-title">' +
                    '<h2 class="archive-year motion-element" id="archive-year-' + currentYear + '" style="opacity: 1;">' + currentYear + '</h2>' +
                    '</div>');
        }
        $(this).addClass("post post-type-normal");
        $("#posts").append($(this));
        counter += 1;
    });

    $.ajax({
        url:CONFIG.APIURL + "/ghost/data",
        method:"get",
        success:function(data)
        {
            if(data.success){
                $("#r-post-total").text(data.data.postNum)
            }
        }
    })
</script>